package com.rinoiot.weather.entity;

import com.rinoiot.weather.entity.Vo.CurrentWeatherVo;
import lombok.Data;

/**
 * 墨迹天气返回天气数据实体类
 */
@Data
public class MojiWeatrherEntity {

    private int code;
    private Data data;
    private String msg;
    private Rc rc;


    @lombok.Data
    public static class City {

        private long cityId;
        private String counname;
        private String name;
        private String pname;
    }

    @lombok.Data
    public static class Data {

        private City city;
        private Condition condition;
    }

    @lombok.Data
    public static class Rc {

        private int c;
        private String p;
    }

    @lombok.Data
    public static class Condition {

        // 实时天气现象
        private String condition;
        // 实时天气id
        private String conditionId;
        // 湿度 %
        private String humidity;
        // 天气icon
        private String icon;
        // 气压
        private String pressure;
        // 体感温度
        private String realFeel;
        // 日出时间
        private String sunRise;
        // 日落时间
        private String sunSet;
        // 温度
        private String temp;
        // 一句话提示
        private String tips;
        // 发布时间
        private String updatetime;
        // 紫外线强度
        private String uvi;
        // 能见度
        private String vis;
        // 风向角度
        private String windDegrees;
        // 风向
        private String windDir;
        // 风级
        private String windLevel;
        // 风速
        private String windSpeed;
    }

    public CurrentWeatherVo trans() {
        CurrentWeatherVo vo = new CurrentWeatherVo();
        vo.setCreateTime(System.currentTimeMillis());
        vo.setDescription(this.getData().getCondition().getCondition());
        vo.setCityName(this.getData().getCity().getName());

        vo.setTemp(String.valueOf(this.getData().getCondition().getTemp()));
        vo.setRealFeel(String.valueOf(this.getData().getCondition().getRealFeel()));
        vo.setHumidity(String.valueOf(this.getData().getCondition().getHumidity()));
        vo.setPressure(String.valueOf(this.getData().getCondition().pressure));
        vo.setVis(String.valueOf(this.getData().getCondition().getVis()));
        vo.setWindDir(this.getData().getCondition().getWindDir());
        vo.setWindSpeed(String.valueOf(this.getData().getCondition().getWindSpeed()));
//        vo.setApi(String.valueOf(this.getData().getCondition().get));
        vo.setSunRise(this.getData().getCondition().getSunRise());
        vo.setSunSet(this.getData().getCondition().getSunSet());
        return vo;
    }

}
